package com.byd.sealmanage.shiro;

import com.alibaba.fastjson.JSONObject;
import com.byd.sealmanage.util.GlobalContants;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName NoPermissionException
 * @Description
 * @Author 👴
 * @Date 2020/5/25 0:37
 * @Version V1.0
 **/
@ControllerAdvice
public class NoPermissionException {
    @ResponseBody
    @ExceptionHandler(UnauthorizedException.class)
    public String handleShiroException(Exception ex) {
        JSONObject json = new JSONObject();
        json.put(GlobalContants.MSG, "无此权限");
        json.put(GlobalContants.RESPCODE, GlobalContants.NUM_404);
        return json.toString();
    }
}
